'=======================================
' 执行所有测试 case
'=======================================
Private Sub test_ALL_case()
    ' offer 测试
    test_offer
    ' poll 测试
    test_poll
    ' peek 测试
    test_peek
    ' Clear 测试
    test_Clear
    ' 保存 Empty 测试
    test_save_empty
End Sub

' offer 测试
Private Sub test_offer()
    Dim q As PrimitiveQueue
    Set q = New PrimitiveQueue
    
    q.offer "aaa"
    Debug.Assert q.Count = 1
    
    q.offer "bbb"
    Debug.Assert q.Count = 2
    
    q.offer Empty
    Debug.Assert q.Count = 3
End Sub

' poll 测试
Private Sub test_poll()
    Dim q As PrimitiveQueue
    Set q = New PrimitiveQueue

    q.offer "aaa"
    Debug.Assert q.Count = 1
    
    q.offer Empty
    Debug.Assert q.Count = 2
    
    q.offer "bbb"
    Debug.Assert q.Count = 3
    
    Dim v As String
    v = q.poll
    Debug.Assert v = "aaa"
    Debug.Assert q.Count = 2
    
    ' 拉取一个 empty 数据
    v = q.poll
    Debug.Assert v = ""
    Debug.Assert q.Count = 1
    
    v = q.poll
    Debug.Assert v = "bbb"
    Debug.Assert q.Count = 0
End Sub

' peek 测试
Private Sub test_peek()
    Dim q As PrimitiveQueue
    Set q = New PrimitiveQueue
    
    q.offer "aaa"
    q.offer Empty
    q.offer "bbb"
    Debug.Assert q.Count = 3
    
    Dim v As Variant
    v = q.peek
    Debug.Assert v = "aaa"
    Debug.Assert q.Count = 3
    q.poll
    
    v = q.peek
    Debug.Assert v = ""
    Debug.Assert q.Count = 2
    q.poll
    
    v = q.peek
    Debug.Assert v = "bbb"
    Debug.Assert q.Count = 1
    q.poll
    
    Debug.Assert q.IsEmpty
End Sub

' Clear 测试
Private Sub test_Clear()
    Dim q As PrimitiveQueue
    Set q = New PrimitiveQueue
    
    q.offer "aaa"
    q.offer Empty
    q.offer "bbb"
    Debug.Assert q.Count = 3
    
    q.Clear
    Debug.Assert q.Count = 0
    Debug.Assert q.IsEmpty = True
End Sub

Private Sub test_Property_01()
    Dim q As PrimitiveQueue
    Set q = New PrimitiveQueue

    Debug.Assert q.IsEmpty = True
    
    q.offer Empty
    q.offer Empty
    q.offer Empty
    
    Debug.Assert q.IsEmpty = False
    Debug.Assert q.Count = 3
End Sub

' 保存 Empty 测试
Private Sub test_save_empty()
    Dim q As PrimitiveQueue
    Set q = New PrimitiveQueue
    
    Debug.Assert q.IsEmpty = True
    
    q.offer Empty
    q.offer Empty
    q.offer Empty
    
    Debug.Assert q.IsEmpty = False
End Sub

